package Http;

import net.rim.device.api.io.transport.ConnectionFactory;
import net.rim.device.api.io.transport.TransportInfo;

/**
 *
 * @author ARMGARCES
 */

/**
 * This class enables you to create HTTP, HTTPS, socket, TLS, and SSL connections over supported transports.
 * This class is not thread-safe and the getConnection() method blocks. So you should not call these methods from the main event thread of an application. 
 */
public class MyConnectionFactory extends ConnectionFactory 
{
	public MyConnectionFactory() 
	{	
		//Sets the preferred transport types used by the factory when attempting to get a connection:		
		setPreferredTransportTypes( new int[] { 
				TransportInfo.TRANSPORT_TCP_WIFI, 
				TransportInfo.TRANSPORT_MDS,
				TransportInfo.TRANSPORT_TCP_CELLULAR
		});

		//Sets the disallowed transport types used by the factory when attempting to get a connection:
		setDisallowedTransportTypes(new int[] {
			TransportInfo.TRANSPORT_WAP2,
			TransportInfo.TRANSPORT_WAP, 
			TransportInfo.TRANSPORT_BIS_B
		});
		

		//Sets the maximum number of attempts the factory will make to create a connection.  The default value is 1. Valid values range from 1 to 500. 
		setAttemptsLimit(10);
		
		//Sets connectionTimeout to the desired value 10sec
		setConnectionTimeout(10000);
		
		//Sets the maximum time the factory will try to create a connection
		setTimeLimit(10000);
	}
}